﻿<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=no, width=device-width">
	<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.1.1/css/bootstrap.css">
	<link rel="stylesheet" href="/assets/plugins/bootstrap/bootstrap.min.css">
	<link rel="stylesheet" href="/assets/css/weixin/sweetalert.css">
	<link rel="stylesheet" type="text/css" href="/assets/css/weixin/timeline.css">
</head>
<body>
	<div class="row">
	  <div class="col-md-12">
        <div class="input-group" style="margin:0 0.625rem; width:96%;margin:0 auto;margin-top:10%;">
          <input type="text" class="form-control exp_id" aria-label="Text input with segmented button dropdown" style="height:3em;font-size:2em;">
          <div class="input-group-btn" style="height:1em;">
            <button type="button" class="btn btn-default exp_bt" style="height:4.3em;">查询(未选择)</button>
            <input type="hidden" value="default" class="exp_bt_v">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="height:4.3em;">
              <span class="caret"></span>
              <span class="sr-only">Toggle Dropdown</span>
            </button>
            <ul class="dropdown-menu dropdown-menu-right exp_company">
              <?php foreach($exp_list as $k => $v){?>
              	<li><a href="#" name="<?php echo $v['code']?>"><?php echo $v['name']?></a></li>
              <?php }?>
              <!-- <li role="separator" class="divider"></li> -->
            </ul>
          </div>
        </div>
      </div>
	</div>
	<div class="row">
		<div class="col-md-12"><section id="cd-timeline" class="cd-container exp_timeline"></section></div>
	</div>
	<script type="text/javascript" src="/assets/plugins/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="/assets/plugins/bootstrap/bootstrap.min.js"></script>
	<script type="text/javascript" src="/assets/js/sweetalert.min.js"></script>
	<script type="text/javascript">
		$('.exp_company li a').on('click',function(){
			var exp_code = $(this).attr('name');
			var exp_name = $(this).html();
			$('.exp_bt').html('查询('+exp_name+')');
			$('.exp_bt_v').val(exp_code);
		});

		$('.exp_bt').on('click',function(){
			var ev = $('.exp_bt_v').val();
			var iv = $('.exp_id').val();
			if(ev == 'default'){
				swal('请先选择快递公司！');
				return false;
			}else if(iv == '' || iv == undefined || iv == null){
				swal('请填写快递单号！');
				return false;
			}else{
				$.ajax({
				  url:"/home/express_detail",
				  type:"POST",
				  data:{name:ev,code:iv},
				  cache:false,
				  dataType:"json",
				  success: function(data) {
				    if(data.code == 0) {
				      $('.exp_timeline').html(data.msg);
				    }else {
				      if(data.msg) {
				        swal(data.msg);
				      } else {
				        swal("提交失败，请稍后尝试！");
				      }
				      return false;
				    }
				  },
				  error: function(e) {
				    swal("提交失败，请稍后尝试！");
				    return false;
				  }
				});
			}

		});
	</script>
</body>
</html>